Kinetis SDK API Reference Manual  1.0.0-beta
Freescale Semiconductor, Inc.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
ENET RTCS Adaptor

The section describes the programming interface of the ENET RTCS Adaptor. More...

Data Structures

struct  ENET_HEADER_PTR
 Define Structure for Ethernet packet header. More...
 
struct  PCB_FRAGMENT_PTR
 Define Structure that contains fragment of PCB. More...
 
struct  PCB_PTR
 Define PCB structure for RTCS adaptor. More...
 
struct  PCB2_PTR
 Define PCB structure contains two fragments. More...
 
struct  pcb_queue
 Define PCB structure contains two fragments. More...
 
struct  ENET_ECB_STRUCT_PTR
 Define ECB structure contains protocol type and it's related service function. More...
 
struct  enet_8022_header_ptr
 Define 8022 header. More...
 
struct  ENET_COMMON_STATS_STRUCT_PTR
 Define common status structure. More...
 
struct  ENET_STATS_PTR
 

Macros

#define ENET_RECEIVE_TASK_PRIO   (_RTCSTASK_priority + 2)
 
#define ENET_TASK_STACK_SIZE   (800)
 
#define ENET_PCB_NUM   (16)
 
#define ENET_RX_RING_LEN   (8)
 Define parameter for configuration.
 
#define ENET_TX_RING_LEN   (4)
 
#define ENET_RX_LARGE_BUFFER_NUM   (0)
 
#define ENET_RX_BUFFER_ALIGNMENT   (16)
 
#define ENET_TX_BUFFER_ALIGNMENT   (16)
 
#define ENET_BD_ALIGNMENT   (16)
 
#define ENET_MII_CLOCK   (2500000L)
 
#define ENET_OK   (0)
 
#define ENET_ERROR   (0xff) /* General ENET error */
 
#define ENETERR_INVALID_DEVICE   (kStatus_ENET_InvalidDevice) /* Device number out of range */
 
#define ENETERR_INIT_DEVICE   (kStatus_ENET_Initialized) /* Device already initialized */
 
#define ENETPROT_IP   0x0800
 Define ENET protocol parameter.
 
#define ENETPROT_ARP   0x0806
 
#define ENETPROT_8021Q   0x8100
 
#define ENETPROT_IP6   0x86DD
 
#define ENETPROT_ETHERNET   0x88F7
 
#define ENET_OPT_8023   0x0001
 
#define ENET_OPT_8021QTAG   0x0002
 
#define ENET_SETOPT_8021QPRIO(p)   (ENET_OPT_8021QTAG | (((uint_32)(p) & 0x7) << 2))
 
#define ENET_GETOPT_8021QPRIO(f)   ((((unsigned int)f) >> 2) & 0x7)
 
#define ENET_OPTION_HW_TX_IP_CHECKSUM   0x00001000
 Define ENET option macro.
 
#define ENET_OPTION_HW_TX_PROTOCOL_CHECKSUM   0x00002000
 
#define ENET_OPTION_HW_RX_IP_CHECKSUM   0x00004000
 
#define ENET_OPTION_HW_RX_PROTOCOL_CHECKSUM   0x00008000
 
#define ENET_OPTION_HW_RX_MAC_ERR   0x00010000
 
#define ENET_DEFAULT_MAC_ADD   { 0x00, 0x00, 0x5E, 0, 0, 0 }
 Define for ENET default MAC.
 
#define PCB_MINIMUM_SIZE   (sizeof(PCB2))
 
#define PCB_free(pcb_ptr)   ((pcb_ptr)->FREE(pcb_ptr))
 
#define htonl(p, x)
 Define macro for byte-swap. More...
 
#define htons(p, x)
 
#define htonc(p, x)
 
#define ntohl(p)
 
#define ntohs(p)
 
#define ntohc(p)   ((uint_8)(((uint_8_ptr)(p))[0]))
 
#define htone(p, x)
 
#define ntohe(p, x)
 
#define QUEUEADD(head, tail, pcb)
 Define add to queue. More...
 
#define QUEUEGET(head, tail, pcb)
 Define get from queue. More...
 

Typedefs

typedef void * task_param_t
 Define Error codes.
 
typedef unsigned char _enet_address [6]
 Define for ENET six-byte MAC type.
 
typedef void * _enet_handle
 Define the structure for ipcfg.
 
typedef void(* PCB_FREE_FPTR )(struct pcb *)
 

Variables

unsigned long _RTCSTASK_priority
 Define Task parameter.
 

ENET RTCS ADAPTOR

uint32_t ENET_initialize (uint32_t device, _enet_address address, uint32_t flag, _enet_handle *handle)
 Initialize the ENET device. More...
 
uint32_t ENET_open (_enet_handle handle, uint16_t type, void(*service)(PCB_PTR, void *), void *private)
 Open the ENET device. More...
 
uint32_t ENET_shutdown (_enet_handle handle)
 Shutdown the ENET device. More...
 
static void ENET_receive (task_param_t param)
 ENET frame receive. More...
 
uint32_t ENET_send (_enet_handle handle, PCB_PTR packet, uint32_t type, _enet_address dest, uint32_t flags)
 ENET frame transmit. More...
 
uint32_t ENET_get_address (_enet_handle handle, _enet_address address)
 ENET get address with initialized device. More...
 
uint32_t ENET_get_mac_address (uint32_t device, uint32_t value, _enet_address address)
 ENET get address with uninitialized device. More...
 
uint32_t ENET_join (_enet_handle handle, uint16_t type, _enet_address address)
 ENET join a multicast group address. More...
 
uint32_t ENET_leave (_enet_handle handle, uint16_t type, _enet_address address)
 ENET leave a multicast group address. More...
 
bool ENET_link_status (_enet_handle handle)
 ENET get link status. More...
 
uint32_t ENET_get_speed (_enet_handle handle)
 ENET get link speed. More...
 
uint32_t ENET_get_MTU (_enet_handle handle)
 ENET get MTU. More...
 
bool ENET_phy_registers (_enet_handle handle, uint32_t numRegs, uint32_t *regPtr)
 Get ENET PHY registers. More...
 
uint32_t ENET_get_options (_enet_handle handle)
 Get ENET options. More...
 
uint32_t ENET_close (_enet_handle handle, uint16_t type)
 Unregisters a protocol type on an Ethernet channel. More...
 
uint32_t ENET_mediactl (_enet_handle handle, uint32_t commandId, void *inOutParam)
 ENET mediactl . More...
 
_enet_handle ENET_get_next_device_handle (_enet_handle handle)
 Get the next ENET device handle address. More...
 
void ENET_free (PCB_PTR packet)
 ENET free . More...
 
const char * ENET_strerror (uint32_t error)
 ENET error description. More...
 

Data Structure Documentation

struct ENET_HEADER

Data Fields

_enet_address DEST
 destination MAC address
 
_enet_address SOURCE
 source MAC address
 
unsigned char TYPE [2]
 protocol type
 
struct PCB_FRAGMENT

Data Fields

uint32_t LENGTH
 Packet fragment length.
 
unsigned char * FRAGMENT
 brief Pointer to fragment
 
struct PCB

Data Fields

PCB_FREE_FPTR FREE
 Function that frees PCB.
 
void * PRIVATE
 Private PCB information.
 
PCB_FRAGMENT FRAG [1]
 Pointer to PCB fragment.
 
struct PCB2

Data Fields

PCB_FREE_FPTR FREE
 Function that frees PCB.
 
void * PRIVATE
 Private PCB information.
 
PCB_FRAGMENT FRAG [2]
 Pointers to two PCB fragments.
 
struct pcb_queue

Data Fields

PCBpcbHead
 PCB buffer head.
 
PCBpcbTail
 PCB buffer tail.
 
struct ENET_ECB_STRUCT

Data Fields

uint16_t TYPE
 
void(* SERVICE )(PCB_PTR, void *)
 
void * PRIVATE
 
struct enet_ecb_struct * NEXT
 
struct enet_8022_header_t

Data Fields

uint8_t dsap [1]
 DSAP region.
 
uint8_t ssap [1]
 SSAP region.
 
uint8_t command [1]
 Command region.
 
uint8_t oui [3]
 OUI region.
 
uint16_t type
 type region
 
struct ENET_COMMON_STATS_STRUCT

Data Fields

uint32_t ST_RX_TOTAL
 Total number of received packets.
 
uint32_t ST_RX_MISSED
 Number of missed packets.
 
uint32_t ST_RX_DISCARDED
 Discarded unrecognized protocol.
 
uint32_t ST_RX_ERRORS
 Discarded error during reception.
 
uint32_t ST_TX_TOTAL
 Total number of transmitted packets.
 
uint32_t ST_TX_MISSED
 Discarded transmit ring full.
 
uint32_t ST_TX_DISCARDED
 Discarded bad packet.
 
uint32_t ST_TX_ERRORS
 Error during transmission.
 
struct ENET_STATS

Data Fields

ENET_COMMON_STATS_STRUCT COMMON
 Common status structure.
 
uint32_t ST_RX_ALIGN
 Frame Alignment error.
 
uint32_t ST_RX_FCS
 CRC error.
 
uint32_t ST_RX_RUNT
 Runt packet received.
 
uint32_t ST_RX_GIANT
 Giant packet received.
 
uint32_t ST_RX_LATECOLL
 Late collision.
 
uint32_t ST_RX_OVERRUN
 DMA overrun.
 
uint32_t ST_TX_SQE
 Heartbeat lost.
 
uint32_t ST_TX_DEFERRED
 Transmission deferred.
 
uint32_t ST_TX_LATECOLL
 Late collision.
 
uint32_t ST_TX_EXCESSCOLL
 Excessive collisions.
 
uint32_t ST_TX_CARRIER
 Carrier sense lost.
 
uint32_t ST_TX_UNDERRUN
 DMA underrun.
 
uint32_t ST_RX_COPY_SMALL
 Driver had to copy packet.
 
uint32_t ST_RX_COPY_LARGE
 Driver had to copy packet.
 
uint32_t ST_TX_COPY_SMALL
 Driver had to copy packet.
 
uint32_t ST_TX_COPY_LARGE
 Driver had to copy packet.
 
uint32_t RX_FRAGS_EXCEEDED
 
uint32_t RX_PCBS_EXHAUSTED
 
uint32_t RX_LARGE_BUFFERS_EXHAUSTED
 
uint32_t TX_ALIGNED
 
uint32_t TX_ALL_ALIGNED
 

Macro Definition Documentation

#define htonl (   p,
 
)
Value:
(((uint_8_ptr)(p))[0] = ((x) >> 24) & 0xFF, \
((uint_8_ptr)(p))[1] = ((x) >> 16) & 0xFF, \
((uint_8_ptr)(p))[2] = ((x) >> 8) & 0xFF, \
((uint_8_ptr)(p))[3] = (x) & 0xFF, \
(x))
#define htons (   p,
 
)
Value:
(((uint_8_ptr)(p))[0] = ((x) >> 8) & 0xFF, \
((uint_8_ptr)(p))[1] = (x) & 0xFF, \
(x))
#define htonc (   p,
 
)
Value:
(((uint_8_ptr)(p))[0] = (x) & 0xFF, \
(x))
#define ntohl (   p)
Value:
(\
(((uint_32)(((uint_8_ptr)(p))[0])) << 24) | \
(((uint_32)(((uint_8_ptr)(p))[1])) << 16) | \
(((uint_32)(((uint_8_ptr)(p))[2])) << 8) | \
( (uint_32)(((uint_8_ptr)(p))[3])) \
)
#define ntohs (   p)
Value:
(\
(((uint_16)(((uint_8_ptr)(p))[0])) << 8) | \
( (uint_16)(((uint_8_ptr)(p))[1])) \
)
#define htone (   p,
 
)
Value:
((p)[0] = (x)[0], \
(p)[1] = (x)[1], \
(p)[2] = (x)[2], \
(p)[3] = (x)[3], \
(p)[4] = (x)[4], \
(p)[5] = (x)[5] \
)
#define ntohe (   p,
 
)
Value:
((x)[0] = (p)[0] & 0xFF, \
(x)[1] = (p)[1] & 0xFF, \
(x)[2] = (p)[2] & 0xFF, \
(x)[3] = (p)[3] & 0xFF, \
(x)[4] = (p)[4] & 0xFF, \
(x)[5] = (p)[5] & 0xFF \
)
#define QUEUEADD (   head,
  tail,
  pcb 
)
Value:
if ((head) == NULL) { \
(head) = (pcb); \
} else { \
(tail)->PRIVATE = (pcb); \
} \
(tail) = (pcb); \
(pcb)->PRIVATE = NULL
#define QUEUEGET (   head,
  tail,
  pcb 
)
Value:
(pcb) = (head); \
if (head) { \
(head) = (head)->PRIVATE; \
if ((head) == NULL) { \
(tail) = NULL; \
} \
}

Function Documentation

uint32_t ENET_initialize ( uint32_t  device,
_enet_address  address,
uint32_t  flag,
_enet_handle handle 
)
Parameters
deviceThe ENET device number.
addressThe hardware address.
flagThe flag for upper layer.
handleThe address pointer for ENET device structure.
Returns
The execution status.
uint32_t ENET_open ( _enet_handle  handle,
uint16_t  type,
void(*)(PCB_PTR, void *)  service,
void *  private 
)
Parameters
handleThe address pointer for ENET device structure.
typeThe ENET protocol type.
serviceThe service function for type.
privateThe private data for ENET device.
Returns
The execution status.
uint32_t ENET_shutdown ( _enet_handle  handle)
Parameters
handleThe address pointer for ENET device structure.
Returns
The execution status.
static void ENET_receive ( task_param_t  param)
static
Parameters
enetIfPtrThe address pointer for ENET device structure.
uint32_t ENET_send ( _enet_handle  handle,
PCB_PTR  packet,
uint32_t  type,
_enet_address  dest,
uint32_t  flags 
)
Parameters
handleThe address pointer for ENET device structure.
packetThe ENET packet buffer.
typeThe ENET protocol type.
destThe destination hardware address.
flagThe flag for upper layer.
Returns
The execution status.
uint32_t ENET_get_address ( _enet_handle  handle,
_enet_address  address 
)
Parameters
handleThe address pointer for ENET device structure.
addressThe destination hardware address.
Returns
The execution status.
uint32_t ENET_get_mac_address ( uint32_t  device,
uint32_t  value,
_enet_address  address 
)
Parameters
handleThe address pointer for ENET device structure.
valueThe value to change the last three bytes of hardware.
addressThe destination hardware address.
Returns
True if the execution status is success else false.
uint32_t ENET_join ( _enet_handle  handle,
uint16_t  type,
_enet_address  address 
)
Parameters
handleThe address pointer for ENET device structure.
typeThe ENET protocol type.
addressThe destination hardware address.
Returns
The execution status.
uint32_t ENET_leave ( _enet_handle  handle,
uint16_t  type,
_enet_address  address 
)
Parameters
handleThe address pointer for ENET device structure.
typeThe ENET protocol type.
addressThe destination hardware address.
Returns
The execution status.
bool ENET_link_status ( _enet_handle  handle)
Parameters
handleThe address pointer for ENET device structure.
Returns
The link status.
uint32_t ENET_get_speed ( _enet_handle  handle)
Parameters
handleThe address pointer for ENET device structure.
Returns
The link speed.
uint32_t ENET_get_MTU ( _enet_handle  handle)
Parameters
handleThe address pointer for ENET device structure.
Returns
The link MTU
bool ENET_phy_registers ( _enet_handle  handle,
uint32_t  numRegs,
uint32_t *  regPtr 
)
Parameters
handleThe address pointer for ENET device structure.
numRegsThe number of registers.
regPtrThe buffer for data read from PHY registers.
Returns
True if all numRegs registers are read succeed else false.
uint32_t ENET_get_options ( _enet_handle  handle)
Parameters
handleThe address pointer for ENET device structure.
Returns
ENET options.
uint32_t ENET_close ( _enet_handle  handle,
uint16_t  type 
)
Parameters
handleThe address pointer for ENET device structure.
Returns
ENET options.
uint32_t ENET_mediactl ( _enet_handle  handle,
uint32_t  commandId,
void *  inOutParam 
)
Parameters
handleThe address pointer for ENET device structure.
Thecommand Id.
Thebuffer for input or output parameters.
Returns
ENET options.
_enet_handle ENET_get_next_device_handle ( _enet_handle  handle)
Parameters
handleThe address pointer for ENET device structure.
Returns
The address of next ENET device handle.
void ENET_free ( PCB_PTR  packet)
Parameters
packetThe buffer address.
const char* ENET_strerror ( uint32_t  error)
Parameters
errorThe ENET error code.
Returns
The error string.